﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Cwjk_Pzz_Edit.aspx.vb" Inherits="PubProject.Cwjk_Pzz_Edit" %>
<%@ Register TagPrefix="cnt" Namespace="Mysoft.Map.Application.Controls" Assembly="Mysoft.Map.Application.Components" %>
<%@ Register TagPrefix="mnu" Namespace="Mysoft.Map.Application.Menus" Assembly="Mysoft.Map.Application.Components" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>凭证字设置</title>
		<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<link rel="stylesheet" type="text/css" href="/_nav/menu.css">
		<link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
		<link rel="stylesheet" type="text/css" href="/_grid/map_grid.css">
		<link rel="stylesheet" type="text/css" href="/_forms/styles/form.css">
		<link rel="stylesheet" type="text/css" href="/_nav/tabs.css">
		<link rel="stylesheet" type="text/css" href="/_nav/nav.css">
		<link rel="stylesheet" type="text/css" href="/_common/styles/select.css">
		<script language="javascript" src="/_controls/settings.aspx"></script>
		<script language="javascript" src="/_controls/setting.js"></script>
		<script language="javascript" src="/_controls/util/util.js"></script>
		<script language="javascript" src="/_controls/datetime/date.js"></script>
		<script language="javascript" src="/_controls/datetime/time.js"></script>
		<script language="javascript" src="/_controls/number/number.js"></script>
		<script language="javascript" src="/_controls/lookup/map_lookup.js"></script>
		<script language="javascript" src="/_controls/lookup/map_lookupDialogs.js"></script>
		<script language="javascript" src="/_nav/menu.js"></script>
		<script language="javascript" src="/_common/scripts/global.js"></script>
		<script language="javascript" src="/PubProject/js/Public.js"></script>
		<script language="javascript">
		//在线帮助文件
		var _MyHelpfile = "/Cbgl/HELP/topics/财务人员/设置财务接口/设置凭证规则.html";
		
	    // 初始化界面
		function window.onload()
		{
		    if (document.all("__mode") && document.all("__mode").value=="1")
            {
                document.all("saveandnew").style.display = "";
            }
            else
            {
                document.all("saveandnew").style.display = "none";
            }
            
		    var sApplication = "";
			var sCwztName = "";
		    var sInitValue = "";
			
			if (!document.getElementById("__Application") || document.getElementById("__Application").value=="")
			{
			    return;
			}
			else
			{
			    sApplication = document.getElementById("__Application").value;
			}
			
			if( document.all("__Application") && document.all("__Application").value=="0101")
            {
                _MyHelpfile = "/Slxt/HELP/topics/财务管理/财务接口设置/设置凭证规则.html"; 
            }
		    
		    if (!document.getElementById("__CwztName") || document.getElementById("__CwztName").value=="")
			{
			    alert("请选择账套！");
			    return;
			}
			else
			{
			    sCwztName = document.getElementById("__CwztName").value;
			}
			
			appForm.appForm_CwztName.value = sCwztName;
			
			if (appForm.GetForm.value!="")
			{
			    sInitValue = appForm.GetForm.value;
			}
			
		    SetGetFormByApplication(sApplication, sInitValue);
        }
					
		//保存数据
		function Save()
		{   
		    if (CheckAppFromValue()!=false)
		    {
		        appForm.Save();
		    }
		}		
		
		//保存并关闭
		function SaveAndNew()
		{
		     if (CheckAppFromValue()!=false)
		     {
		        appForm.SaveAndNew();
		     }
		}
		
		//保存并关闭
		function SaveAndClose()
		{
		     if (CheckAppFromValue()!=false)
		     {
		        appForm.SaveAndClose();
		     }
		}
		
		function CheckAppFromValue()
		{
		    return true;
		}

		function oprBeforeSave()
		{
			if (appForm.CwztGUID.value=="")
			{
			    alert("请选择账套！");
			    event.returnValue = false;
			    return;
			}
			
			if (appForm.OperType.value!="" && appForm.GetForm.value!="" && (appForm.OperType.value!=appForm.appForm_OperType_Old.value || appForm.GetForm.value!=appForm.appForm_GetForm_Old.value))
			{
			    //判断 业务类型 和 支付方式是否重复
		        var sPath = "/PubProject/Cwjk/Cwjk_XMLHTTP.aspx?CwztGUID="+ escape(appForm.CwztGUID.value) +"&OperType=" + escape(appForm.OperType.value) + "&GetForm=" + escape(appForm.GetForm.value);
		        
		        var sResults = openXMLHTTP(sPath,"CheckPzzIsRepeated");
                
                if (sResults.split('|')[0]=="YES")
                {
                    alert("业务类型和支付方式重复，请重新录入！");
                    event.returnValue = false;
                    return;
                }
            }
            
			event.returnValue = true;
		}
		
		function oprAfterSave()
		{
		  	var xmlDom = new ActiveXObject("Microsoft.XMLDOM")
		  	
	        try
	        {
		        xmlDom.loadXML(appForm.returnxml);
		        
		        if (xmlDom.documentElement.attributes.getNamedItem("result").value == "true")
	            {
	                //刷新父窗口页面
	                ParentGridRefresh();

		            event.returnValue = true;
	            }
	            else
	            {
	                alert("保存失败，请与系统管理员联系！");
	            }
	        }
	        catch(e)
	        {
		        alert("返回的xml格式错误，请与管理员联系！");
		        return;
	        }
		}
		
		//刷新父窗口页面
		function ParentGridRefresh()
		{
			//刷新主界面
			try
			{
				window.opener._appGrid_Query(appForm.PzzGUID.value);		// 刷新网格 id="appGrid"
			}
			catch(e)
			{
			}
		}
		
		//根据 Application 设定 GetForm 的值
		function SetGetFormByApplication(sApplication, sInitValue)
		{
		    var sXML = "";
		    
		    if (sApplication=="0101")
		    {
		        sXML = "<items><item text=\"现金\" value=\"现金\" /><item text=\"银行\" value=\"银行\" /><item text=\"转账\" value=\"转账\" /></items>";
		    }
		    else
		    {
		        sXML = "<items><item text=\"现金\" value=\"现金\" /><item text=\"银行\" value=\"银行\" /></items>";
		    }

			RefreshDLLItem("GetForm", sXML, sInitValue);
		}
		</script>
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<table class="layout" cellSpacing="0" cellPadding="0">
			<COLGROUP>
				<col width="140"> <!-- 导航菜单：140px -->
				<col>
			</COLGROUP>
			<tr height="48" id="trzc">
				<td colSpan="2">
					<!-- 菜单 --><mnu:appformmenu id="appFormMenu" runat="server"></mnu:appformmenu></td>
			</tr>
			<tr>
				<td colSpan="2">
					<div class="area">
						<cnt:AppForm id="appForm" runat="server" processtype="xmlhttp" assembly="Mysoft.Map.Core" invokeclass="Mysoft.Map.Data.MyDB" invokefunction="SaveXml" onbeforesave="oprBeforeSave()" onaftersave="oprAfterSave()"></cnt:AppForm>
					</div>
				</td>
			</tr>
		</table>
		<form id="Form1" runat="server">
		</form>
	</body>
</HTML>
